package eu.jpereira.trainings.designpatterns.structural.decorator.channel.decorator;

import eu.jpereira.trainings.designpatterns.structural.decorator.channel.SocialChannel;

public class WordCensor extends SocialChannelDecorator {

	private String censoredWord = "";
	
	public WordCensor(String word) {
		this.censoredWord = word;
	}
	
	public WordCensor(String word, SocialChannel channel) {
		this.censoredWord = word;
		this.delegate = channel;
	}
	
	@Override
	public void deliverMessage(String message) {
		message = message.replaceAll(censoredWord, "###");
		delegate.deliverMessage(message);
	}

}
